﻿using PlayerRoles;
using System.Collections.Generic;


namespace RoundTicks.Config
{
    public class ConfigRoundTicks
    {
        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnabled { get; set; } = false;

        /// <summary>
        /// 条件|触发人数
        /// </summary>
        public int TriggerPlayers { get; set; } = 1;


        /// <summary>
        /// 条件组|异常数
        /// </summary>
        public int GroupSCP { get; set; } = 1;

        /// <summary>
        /// 条件组|科学家数
        /// </summary>
        public int GroupScientist { get; set;} = 1;
        
        /// <summary>
        /// 条件组|安保数
        /// </summary>
        public int GroupGuard { get; set; } = 2;

        /// <summary>
        /// 条件组|D级数
        /// </summary>
        public int GroupClassD { get; set; } = 3;


        public int GetCount()
        {
            int result = 0;

            if (GroupSCP >= 1) result += GroupSCP;
            if (GroupScientist >= 1) result += GroupScientist;
            if (GroupGuard >= 1) result += GroupGuard;
            if (GroupClassD >= 1) result += GroupClassD;

            return result;
        }



        public List<RoleTypeId> GetGorupRole()
        { 
            var output = new List<RoleTypeId>();

            if (CanResfreshClassD())
            {
                for (int i = 0; i < GroupClassD; i++)
                {
                    output.Add(RoleTypeId.ClassD);
                }
            }

            if (CanResfreshScientist())
            {
                for (int i = 0; i < GroupScientist; i++)
                {
                    output.Add(RoleTypeId.Scientist);
                }
            }

            if (CanResfreshGuard())
            {
                for (int i = 0; i < GroupGuard; i++)
                {
                    output.Add(RoleTypeId.FacilityGuard);
                }
            }

            return output;
        }




        public bool CanResfreshSCP()
        {
            return GroupSCP >= 1;
        }

        public bool CanResfreshScientist() {  return GroupScientist >= 1; }

        public bool CanResfreshGuard() {  return GroupGuard >= 1; }

        public bool CanResfreshClassD() {  return GroupClassD >= 1; }
    }
}
